<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@ page contentType="text/html;charset=UTF-8"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html>
<head>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/ajax-1.0.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery_last.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery-1.4.2.min.js"></script>
	<!-- 
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery-impromptu.2.7.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery-selected.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery-ui-1.8.16.custom.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.form.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.form.wizard.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.js"></script>
 <script type="text/javascript"	src="<%=request.getContextPath()%>/js/jQuery/jquery.lazyload.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.treeview.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.validate.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.min.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jQuery/jquery.timer.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jquery.timers-1.2.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/jquery.1.3.2.js"></script>
<script type="text/javascript"
	src="<%=request.getContextPath()%>/js/popup_layer.js"></script>
	-->
<link href="<%=request.getContextPath()%>/css/core.css" type="text/css"
	rel="stylesheet">
<script type='text/javascript' src='/RbBg/dwr/engine.js'></script>
<script type='text/javascript' src='/RbBg/dwr/interface/DwrService.js'></script>
<script type='text/javascript' src='/RbBg/dwr/util.js'></script>
<title>Send To ATG</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
</head>
<script type="text/javascript">
	$(document).ready(function() {
	var interval = "";
	$("#b04").click(function() {

		var b04refundNo = $("#b04refundNo").val();
		var ambiento = $("#ambiento").val();
		//var b04refundDetailsId = $("#b04refundDetailsId").val();
		var url = "<%=request.getContextPath()%>/service.do?method=rbswr&refundNo="
													+ b04refundNo+"&ambient="+ambiento;
											$.ajax({type : "post",
														url : url,
														datatype : "json",
														contentType : "application/x-www-form-urlencoded; charset=utf-8",
														success : function(
																data) {
																var json = eval(data); 
																var tar = "<hr\/>";
                                                                 tar+= "<TABLE style=\"BORDER-COLLAPSE: collapse\"  border=\"1\" cellSpacing=\"0\" ><TBODY >";  
                                                                 tar+="<tr><td align=\"left\" >退款单号</td><td align=\"left\" >退款明细</td><td align=\"left\">退款流水号</td><td align=\"left\">退款金额</td><td align=\"left\">退款状态</td><td align=\"left\">发送状态</td><td align=\"left\">退款方式</td></tr>";  
	                                                                $.each(json,function(idx,item) {
                                                                 tar+="<tr   class=\"trm\" id=\"ele9\"  onclick=\"javascript:view("+idx+");\"><td align=\"left\" id=\"tb"+idx+"\" >"+item.refundNo+"</td><td align=\"left\" id=\"tp"+idx+"\">"+item.refundDetailsId+"</td><td align=\"left\">"+item.refundTradeNo+"</td><td align=\"left\">"+item.refundAmount+"</td><td align=\"left\">"+item.taskState+"</td><td align=\"left\">"+item.refundState+"</td><td align=\"left\">"+item.bankType+"</td></tr>";
																			});
                                                                tar+="</TBODY></TABLE>";  
                                                                $("#b03").html(tar); 
                                                                $("tbody tr:odd").css("background-color","#eee"); 
                                                                $("#test tr").each(function () {                
                                                                     //  alert($(this).children('td').eq(1).html());
                                                                      // alert($(this).find('td').eq(0).text());
                                                                                     });
                                                                                     
                                                                                     
                                                                   $(".trm").click(function(){
                                                                   
					                                               // alert($(this).find('td').eq(0).text());
					                                               // alert($(this).find('td').eq(1).text());
																   
																     $("#refundNo").val($(this).find('td').eq(0).text()); 
																    $("#refundDetailsId").val($(this).find('td').eq(1).text()); 						
																	  $("#refundTradeNo").val($(this).find('td').eq(2).text()); 
																	   $("#banktype").val($(this).find('td').eq(6).text()); 
					                                               
					                                                var refundNo = $(this).find('td').eq(0).text();
		                                                            var ambient = $(this).find('td').eq(1).text();
		                                                            var ambiento = $("#ambiento").val();
		    
		                                     var url = "<%=request.getContextPath()%>/service.do?method=rbswrfl&refundNo="+refundNo+"&ambient="+ambiento;
					                                  $.ajax({type : "post",
														url : url,
														datatype : "json",
														contentType : "application/x-www-form-urlencoded; charset=utf-8",
														success : function(
																datas) {
																
																var jsons = eval(datas);
																var tars = "<hr\/>"; 
                                                                 tars+= "<TABLE style=\"BORDER-COLLAPSE: collapse\"  border=\"1\" cellSpacing=\"0\" ><TBODY >";  
                                                                 tars+="<tr><td align=\"left\" >退款单号</td><td align=\"left\" >退款明细</td><td align=\"left\">错误记录</td></tr>";  
	                                                                $.each(jsons,function(idxc,item) {
                                                                 tars+="<tr><td align=\"left\">"+item.refundNo+"</td><td align=\"left\">"+item.refundDetailsId+"</td><td align=\"left\">"+item.logContent+"</td></tr>";
																			});
                                                                tars+="</TBODY></TABLE>";  
                                                                 $("#b09").html(tars); 
                                                                 $("#m04").html(tars); 
                                                                  $("tbody tr:odd").css("background-color","yello");  
                                                                  
																  
																  
																
																
                                           
                                                                 
																	  
                                                                  
	                                              
																				}
});
																			});

														},
														error : function(
																XMLHttpRequest,
																textStatus,
																errorThrown) {
															alert(errorThrown);
														}
													});
										});

						$("#b01").click(function() {
							var refundNo = $("#refundNo").val();
							var refundDetailsId = $("#refundDetailsId").val();
							var rstate = $("#rstate").val();
							var ambient = $("#ambient").val();
							var refundTradeNo = $("#refundTradeNo").val();
							var banktype = $("#banktype").val();
							var obj = {
								"refundNo" : refundNo,
								"refundDetailsId" : refundDetailsId,
								"refundState" : rstate,
								"refundTradeNo" : refundTradeNo,
								"banktype" : banktype,
								"refundService" : ambient,
							}
							DwrService.getInfo(obj, callBackFun);
							function callBackFun(data) {
								alert(data);
							}
						});
						
						
						$("#b08").click(function() {
						
						 $("#b08").attr("disabled", true);
                         $("#b08").val("正在截取.....");
						  interval =  setInterval("startRequest()",5000);
						});
						
						$("#b012").click(function() {
						
						  clearInterval(interval);
						  $("#b08").attr("disabled", false);
                          $("#b08").val("提交");
                        
						});
					});
	function view(obj) {
		var s = "#bb" + obj;
		$(s).css("background-color", "#eef");
	}
function consoleInfo(){
    
}

	
	  function startRequest()
            {
            var refundNo = $("#b05refundNo").val();
		    var ambient = $("#b05ambient").val();
		    var url = "<%=request.getContextPath()%>/service.do?method=rbuwr&refundNo="+refundNo+"&ambient="+ambient;
			$.ajax({type : "post",
														url : url,
														datatype : "json",
														contentType : "application/x-www-form-urlencoded; charset=utf-8",
														success : function(
																data) {
																if(data=="1"){
																 $("#b08").attr("disabled", true);
                                                                 $("#b08").val("已截取");
																   return true;
																}else{
																  
																  return false;
																}
	                                                              }
                                                               
             });								
		    
		    
		  
       }
</script>

<body>


<h1>RB各环境手动推送退款状态</h1>


	<div id="emample9" class="example">

      <!-- 
		退款单号 : <input id="b05refundNo" name="b05refundNo" type="text" /> 测试环境
		: <select id="b05ambient" name="b05ambient">
			<option value='sit'>sit</option>
			<option value='uat'>uat</option>
			<option value='pre'>预生产</option>
			
		</select> <input id="b08" type="button" value="提交" /> <input id="b012"
			type="button" value="停止截取" />
				<hr />	
			 -->
	

		退款单号 : <input id="b04refundNo" name="b04refundNo" type="text" /> 测试环境
		: <select id="ambiento" name="ambiento">
			<option value='sit'>sit</option>
			<option value='uat'>uat</option>
			<option value='pre'>预生产</option>
			
		</select> <input id="b04" type="button" value="提交" />


		<div id="b03"></div>
		<div id="b09"></div>



		<hr />
		退款单号 : <input id="refundNo" name="refundNo" type="text" /> 
		退款明细 : <input id="refundDetailsId" name="refundDetailsId" type="text" /> 
		<input id="refundTradeNo" name="refundTradeNo" type="hidden" /> 
		<input id="banktype" name="banktype" type="hidden" /> 
		返回状态 : <select
			id="rstate" name="rstate">
			<option value='S'>S</option>
			<option value='E'>E</option>
		</select> 测试环境 : <select id="ambient" name="ambient">
			<option value='sit'>sit</option>
			<option value='uat'>uat</option>
			<option value='pre'>预生产</option>
			
		</select> <input id="b01" type="button" value="提交" />

	</div>
</body>
</html>